<?php

require "../utility.php";

function delAddrFromDatabase(mysqli $conn, string $id): bool {
    $insert_str = "DELETE FROM Addr WHERE ID = ?;";
    $insert_stmt = $conn->prepare($insert_str);
    $insert_stmt->bind_param("i", $id);
    $status = $insert_stmt->execute();
    return $status;
}

$conn = connect_mysql();
$user_id = getUserIdBySessionId($conn); // 用于判断用户是否登录

http_response_code(403);

if ($user_id !== null       &&
    check_keys($_GET, "id")) {
    
    $id = $_GET["id"];
    if (delAddrFromDatabase($conn, $id)) {
        // success
        http_response_code(200);
    }
}

$conn->close();

?>